package org.vs.handler.responsibilitychain.vote;

import com.alibaba.fastjson2.JSON;
import org.springframework.stereotype.Component;
import org.vs.annotation.CheckBalance;
import org.vs.domain.vo.ProgressVO;
import org.vs.handler.responsibilitychain.BaseResponsibilityChainHandler;

@Component
public class VotePublishCompleteHandler extends BaseResponsibilityChainHandler {

    @CheckBalance
    @Override
    protected boolean customerHandler(Object obj) {
        VotePublishHandlerEO votePublishHandlerEO = (VotePublishHandlerEO) obj;

        votePublishHandlerEO.setCount(votePublishHandlerEO.getCount() + 1);
        setHandler(null);
        setMessage(votePublishHandlerEO.getHashcode(), JSON.toJSONString(ProgressVO
                .builder()
                .progress((100 / voteCount) * votePublishHandlerEO.getCount())
                .info("完成")
                .build()));

        return true;
    }
}
